package cn.xopencode.recordservice.provider.pdroom;

import cn.xopencode.common.framework.vo.CommonResult;
import cn.xopencode.common.framework.vo.PageResult;
import cn.xopencode.recordservice.manager.pdroom.PowerDistributionRoomManager;
import cn.xopencode.recordservice.rpc.pdroom.PowerDistributionRoomRpc;
import cn.xopencode.recordservice.rpc.pdroom.dto.PowerDistributionRoomCreateDTO;
import cn.xopencode.recordservice.rpc.pdroom.dto.PowerDistributionRoomPageDTO;
import cn.xopencode.recordservice.rpc.pdroom.dto.PowerDistributionRoomQueryDTO;
import cn.xopencode.recordservice.rpc.pdroom.dto.PowerDistributionRoomUpdateDTO;
import cn.xopencode.recordservice.rpc.pdroom.vo.PowerDistributionRoomPageVO;
import cn.xopencode.recordservice.rpc.pdroom.vo.PowerDistributionRoomUpdateVO;
import cn.xopencode.recordservice.rpc.pdroom.vo.PowerDistributionRoomVO;
import org.apache.dubbo.config.annotation.DubboService;
import org.springframework.beans.factory.annotation.Autowired;

import java.util.List;
import java.util.Map;

/**
 * 配电室 Rpc 实现类
 */
@DubboService(version = "${dubbo.provider.PowerDistributionRoomRpc.version}")
public class PowerDistributionRoomRpcImpl implements PowerDistributionRoomRpc {

    @Autowired
    private PowerDistributionRoomManager powerDistributionRoomManager;

    @Override
    public CommonResult<Integer> createPowerDistributionRoom(PowerDistributionRoomCreateDTO createDTO) {
       Integer result = powerDistributionRoomManager.createPowerDistributionRoom(createDTO);
       return CommonResult.success(result);
    }

    @Override
    public CommonResult<Integer> updatePowerDistributionRoom(PowerDistributionRoomUpdateDTO updateDTO) {
        Integer result = powerDistributionRoomManager.updatePowerDistributionRoom(updateDTO);
        return CommonResult.success(result);
    }

    @Override
    public CommonResult<PageResult<PowerDistributionRoomPageVO>> pagePowerDistributionRoom(PowerDistributionRoomPageDTO pageDTO) {
        return CommonResult.success(powerDistributionRoomManager.pagePowerDistributionRoom(pageDTO));
    }

    @Override
    public CommonResult<List<PowerDistributionRoomVO>> getPowerDistributionRoomList(String roomName) {
        List<PowerDistributionRoomVO> roomVOList = powerDistributionRoomManager.getPowerDistributionRoomList(roomName);
        return CommonResult.success(roomVOList);
    }

    @Override
    public CommonResult<PowerDistributionRoomUpdateVO> getPowerDistributionRoomById(String id) {
        return CommonResult.success(powerDistributionRoomManager.getPowerDistributionRoomById(id));
    }

    @Override
    public CommonResult<Integer> changeStatus(String roomId, Boolean flag) {
        return CommonResult.success(powerDistributionRoomManager.changeStatus(roomId, flag));
    }

    @Override
    public CommonResult<Map<String, String>> getLineNameByParam(PowerDistributionRoomQueryDTO queryDTO) {
        return CommonResult.success(powerDistributionRoomManager.getLineNameByParam(queryDTO));
    }

    @Override
    public CommonResult<List<PowerDistributionRoomVO>> getPdroomNameListByType(Integer recordType) {
        return CommonResult.success(powerDistributionRoomManager.getPdroomNameListByType(recordType));
    }
}
